/** m2settings is a GUI to configure Maven 2 settings.xml 
 * 
 *  Copyright (C) 2007 Regis Decamps <decamps@users.sf.net>
 * 
 *  This file is part of m2settings.
 *
 *  m2settings is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version. 
 *
 *  Foobar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *  or read it online http://www.gnu.org/licenses/gpl.txt
 *
 **/
package info.decamps.m2settings.model;

import javax.swing.event.TableModelEvent;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import org.apache.commons.lang.StringUtils;

/**
 * An <code>ExtendableTableModel</code> is a <code>TableModel</code> in whi rows
 * can be added or removed.
 *
 * @author regis
 *
 */
public abstract class ExtendableTableModel extends AbstractTableModel implements TableModel {
    protected String[] columnTitles;
    /**
     * Remove row at the given indexes.
     * @param rowIndexes
     */
    public abstract void removeRows(int[] rowIndexes);
    
    /**
     * Removes the row placed at the given index.
     * @param index
     */
//	/public void removeRow(int index);
    
    /**
     * The descriptive name of the element manipulated by this model.
     */
    public abstract String getElementName();
    
    
    public boolean isCellEditable(int arg0, int arg1) {
        return false;
    }
    
    public int getColumnCount() {
        return columnTitles.length;
    }
    
    public String getColumnName(int index) {
        return columnTitles[index];
    }
    
    public void fireChange(int index) {
        fireTableChanged(new TableModelEvent(this, index, index));
    }
    
    /**
     * Mask all characters with stars.
     */
    public static String charToStars(String s) {
        if (StringUtils.isEmpty(s))
            return null;
        return s.replaceAll(".","*");
    }
}
